Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): adds vip qr code modal #3991

Merged
merged 135 commits into from
Jan 9, 2025

Conversation

BonomoAlessandro
Copy link
Collaborator

@BonomoAlessandro BonomoAlessandro commented Dec 16, 2024

Motivation

Vip users should be able to create reward codes and get qr codes to show them to other clients.

Changes

  • adds vip reward modal

Tests

qr code modal:
image

BonomoAlessandro and others added 30 commits December 16, 2024 10:39
… into feature(frontend)/adds-vip-qr-code-modal
…r-codes-option-in-menu' into feature(frontend)/displays-vip-qr-codes-option-in-menu

# Conflicts:
#	src/declarations/backend/backend.did.d.ts
…r-codes-option-in-menu' into feature(frontend)/displays-vip-qr-codes-option-in-menu
@BonomoAlessandro BonomoAlessandro marked this pull request as ready for review January 7, 2025 13:45
@BonomoAlessandro BonomoAlessandro requested a review from a team as a code owner January 7, 2025 13:45
<span class="w-full"><SkeletonText /></span>
{/if}

<ButtonGroup styleClass="flex-col sm:flex-row" slot="toolbar">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really sure about this: we don't do it in any of the modals, nor in any usage of the Buttons... if we are going to change it, better to do it in another PR for all the ButtonGroup components, for consistency

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntonioVentilii What exactly do you mean with

for all the ButtonGroup components, for consistency

I mean like this we just enable to add some custom styling to the element

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, but why only for this modal? why not for all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's defined like this in the design. The buttons should swap the alignment if the page gets smaller. To achieve this on this modal we need something like this.
Other modals do not need to swap the alignment

Copy link
Collaborator

@AntonioVentilii AntonioVentilii Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not convinced about this... may you please double-check with design (especially if it's ONLY for this modal)? furthermore, will the "Close" button go up or down when it is vertical (i.e. flex-col-reverse)?

Screenshot 2025-01-09 at 14 45 45

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntonioVentilii @artkorotkikh-dfinity just wrote me that he updated the designs.

src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
/>
</div>

<span class="mb-4 block w-full pt-3 text-center text-sm text-tertiary">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think block is default, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not default

Copy link
Member

@peterpeterparker peterpeterparker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it expected to have no overall limit on polling? For example, a VIP user could open this particular screen, forget the tab, and continuously generate codes every 45 seconds for the entire duration of the session.

src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
};

onMount(() => {
countdown = setInterval(intervalFunction, 1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't countdown be cleared on destroy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a good point, thx

countdown = setInterval(intervalFunction, 1000);
});

generateCode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this finds place at the root of the module? Shouldn't it start when the component is mounted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yes this should be moved into the onMount function

@BonomoAlessandro
Copy link
Collaborator Author

Is it expected to have no overall limit on polling? For example, a VIP user could open this particular screen, forget the tab, and continuously generate codes every 45 seconds for the entire duration of the session.

Good input. I will change it that way that it only generates new codes as long as the tab is active.

return;
}

if (retries !== maxRetries) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid an edge case issue, < maybe? Otherwise it might retries if the number of retries is bigger than the max retries.

src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
let counter = VIP_CODE_REGENERATE_INTERVAL;
let countdown: NodeJS.Timeout | undefined;
const maxRetries = 3;
let retries = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better readability, could you either add a comment indicating that this is for retries in case of errors or rename the variable to make it more explicit?


const regenerateCode = async () => {
clearInterval(countdown);
await generateCode();
Copy link
Member

@peterpeterparker peterpeterparker Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the retries be asserted here? With the current implementation, we might indeed prevent any further calls, but the countdown would still proceed. Not a strong opinion, just a thought.

src/frontend/src/lib/constants/app.constants.ts Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
src/frontend/src/lib/components/qr/VipQrCodeModal.svelte Outdated Show resolved Hide resolved
Copy link
Member

@peterpeterparker peterpeterparker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Given that I stricly only reviewed the script tag of VipQrCodeModal.svelte, please also wait for @AntonioVentilii approval to merge this PR.

<div class="mx-auto mb-4 aspect-square h-80 max-h-[44vh] max-w-full p-4">
{#if nonNullish(code)}
<QRCode value={qrCodeUrl}>
<div slot="logo" class="flex items-center justify-center rounded-lg bg-white p-2">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't slot="logo" go in the parent div two levels above?

<div slot="logo" class="mx-auto mb-4 aspect-square h-80 max-h-[44vh] max-w-full p-4">
  {#if nonNullish(code)}
    <QRCode value={qrCodeUrl}>
	    <div class="flex items-center justify-center rounded-lg bg-white p-2">

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntonioVentilii No it is a part of the QRCode

<span class="w-full"><SkeletonText /></span>
{/if}

<ButtonGroup styleClass="flex-col sm:flex-row" slot="toolbar">
Copy link
Collaborator

@AntonioVentilii AntonioVentilii Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not convinced about this... may you please double-check with design (especially if it's ONLY for this modal)? furthermore, will the "Close" button go up or down when it is vertical (i.e. flex-col-reverse)?

Screenshot 2025-01-09 at 14 45 45

Copy link
Collaborator

@AntonioVentilii AntonioVentilii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM tks!!

@BonomoAlessandro BonomoAlessandro merged commit cefc22b into main Jan 9, 2025
22 checks passed
@BonomoAlessandro BonomoAlessandro deleted the feature(frontend)/adds-vip-qr-code-modal branch January 9, 2025 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants